#ifndef EMAILSENDER_H
#define EMAILSENDER_H

#include <QObject>
#include <QSslSocket>
#include <QString>

class EmailSender : public QObject
{
    Q_OBJECT
public:
    explicit EmailSender(QObject *parent = nullptr);
    void sendVerificationCode(const QString &recipientEmail, const QString &code);

signals:
    void sendSuccess();       // 发送成功信号
    void sendFailed(const QString &errorMsg);  // 发送失败信号

private slots:
    void onConnected();       // 连接服务器成功
    void onReadyRead();       // 接收服务器响应
    void onErrorOccurred(QAbstractSocket::SocketError error);  // 错误处理
    void onSslErrors(const QList<QSslError> &errors);  // SSL错误处理

private:
    QSslSocket *m_socket;
    QString m_recipient;      // 收件人邮箱
    QString m_verificationCode;  // 验证码

    const QString SMTP_SERVER = "smtp.qq.com";
    const int SMTP_PORT = 587;
    const QString SENDER_EMAIL = "1572015465@qq.com";
    const QString SENDER_AUTH_CODE = "pkznbjdxehyvbadh";
};

#endif // EMAILSENDER_H
